package 剑指offer;

/**
 * @description:
 * @author: ywk
 * @date: 2020-10-28
 */
public class 反转字符串 {
    public static void main(String[] args) {
        System.out.println(solve("reverse"));
    }

    public static String solve(String str) {
        // write code here
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length / 2; i++) {
            int end = chars.length - 1 - i;
            char temp = chars[i];
            chars[i] = chars[end];
            chars[end] = temp;
        }
        return new String(chars);
    }
}
